package com.naive.imperative.program;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;


public abstract class OperationBlock implements Iterable<Operation> {
	private final List<Operation> children = new ArrayList<Operation>();

	public void add(Operation c) {
		children.add(c);
	}

	public void remove(Operation c) {
		children.remove(c);
	}

	public Iterator<Operation> iterator() {
		return children.iterator();
	}
	/** just a shortcut for executing all its operations sequentially
	 * 
	 */
	public void execute(ExecutionContext c) {
		c.startBlock(this);
		for(Operation o: this) {
			o.execute(c);
		}
		c.endBlock(this);
}
	public abstract boolean isAllowed(Operation od);
}
